/* App-base.css - 基础布局和通用样式 */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 10001; /* 添加z-index，确保标题栏在显示按钮之上 */
}

h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
  color: #333;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.settings-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.settings-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.theme-selector {
  display: flex;
  gap: 0.5rem;
}

.theme-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.theme-btn.active {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
}

.editor-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  margin: 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.editor,
.preview {
  flex: 1;
  overflow: auto;
  padding: 0.8rem; /* 进一步减少内边距 */
  box-sizing: border-box;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  margin: 0.2rem; /* 进一步减少外边距 */
  /* 防止子元素影响容器尺寸 */
  contain: layout style;
}

.editor {
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

/* 工具栏包装器 */
.toolbar-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 优化过渡效果，使用更丝滑的缓动函数 */
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999; /* 提高z-index，确保工具栏在大部分元素之上 */
  overflow: visible; /* 添加此行以确保下拉菜单能够正确显示 */
}

/* 工具栏显示按钮 */
.toolbar-show-button {
  padding: 0.2rem 0.5rem;
  border: none;
  background-color: rgba(102, 126, 234, 0.7);
  color: white;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  width: 60px;
  text-align: center;
  margin: 0;
  z-index: 10000; /* 保持z-index，但确保低于标题栏 */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(-10px);
}

/* 工具栏显示按钮出现时的状态 */
.toolbar-show-button.show {
  opacity: 1;
  transform: translateY(0);
}

.toolbar-show-button:hover {
  background-color: rgba(102, 126, 234, 0.8);
}

/* 横向工具栏样式 */
.toolbar {
  display: flex;
  flex-direction: row;
  padding: 0;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  z-index: 10001; /* 提高z-index，确保工具栏在大部分元素之上 */
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 95%;
  max-width: 1200px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  /* 优化过渡效果，使用更丝滑的缓动函数 */
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  min-height: 40px;
  /* 设置初始位置，为显示动画做准备 */
  transform: translateY(-20px);
  opacity: 0;
}

/* 工具栏展开状态 */
.toolbar.open {
  height: auto;
  padding: 0.75rem;
  overflow: visible; /* 改为visible，确保下拉菜单能够显示 */
  opacity: 1;
  /* 显示动画：向下浮现 */
  transform: translateY(0);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 工具栏收起状态 */
.toolbar.collapsed {
  height: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: none;
  box-shadow: none;
  margin-top: 0;
  opacity: 0;
  /* 隐藏动画：向上浮出 */
  transform: translateY(-20px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 工具栏切换按钮 */
.toolbar-toggle {
  padding: 0.2rem 0.5rem;
  border: none;
  background-color: rgba(102, 126, 234, 0.7);
  color: white;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: absolute;
  top: 100%;
  left: 50%;
  width: 60px;
  text-align: center;
  margin: 0;
  z-index: 9990; /* 降低z-index，确保在工具栏之下 */
  opacity: 0;
  /* 修复：合并transform属性，避免冲突 */
  transform: translateX(-50%) translateY(10px);
}

/* 工具栏切换按钮出现时的状态 */
.toolbar-toggle.show {
  opacity: 1;
  /* 修复：保持transform一致性 */
  transform: translateX(-50%) translateY(0);
}

.toolbar-toggle:hover {
  background-color: rgba(102, 126, 234, 0.8);
}

/* 工具栏内容 */
.toolbar-content {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  overflow: visible;
  width: 100%;
  align-items: center;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  /* 移除transform，改用margin实现动画 */
  margin-top: -10px;
  opacity: 0;
  position: relative;
}

/* 工具栏展开时的内容状态 */
.toolbar.open .toolbar-content {
  margin-top: 0;
  opacity: 1;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar-content button {
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  /* 修复：添加最小高度以确保按钮高度一致 */
  min-height: 32px;
}

.toolbar-content button:hover {
  background-color: rgba(220, 220, 220, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  /* 发光光晕阴影特效 - 主题色适配 */
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 0 15px rgba(102, 126, 234, 0.4);
  filter: brightness(1.1);
}

/* 主题色适配的发光光晕阴影 */
.light .toolbar-content button:hover {
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 0 15px rgba(102, 126, 234, 0.4);
}

.dark .toolbar-content button:hover {
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 0 15px rgba(255, 255, 255, 0.4);
}

.blue .toolbar-content button:hover {
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 0 15px rgba(33, 150, 243, 0.4);
}

.green .toolbar-content button:hover {
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 0 15px rgba(76, 175, 80, 0.4);
}

.purple .toolbar-content button:hover {
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 0 15px rgba(156, 39, 176, 0.4);
}

/* 工具栏按钮微光效果 */
.toolbar-content button {
  position: relative;
  overflow: hidden;
}

.toolbar-content button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  border-radius: 6px;
}

.toolbar-content button:hover::before {
  opacity: 1;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* 数学公式样式 */
.math-inline {
  display: inline-block;
  margin: 0 0.1em; /* 减少左右边距 */
  vertical-align: middle; /* 垂直居中对齐 */
}

.math-block {
  display: block;
  text-align: center;
  margin: 0.1em 0; /* 减少上下边距 */
  padding: 0.2em 0; /* 使用内边距替代部分外边距 */
  line-height: 1.2; /* 控制行高 */
  overflow-x: auto; /* 允许横向滚动 */
  overflow-y: hidden; /* 防止纵向滚动 */
}

.math-error {
  color: #ff0000;
  font-style: italic;
}

/* 移动端适配媒体查询 */
@media screen and (max-width: 768px) {
  /* 调整主容器布局 */
  .editor-container {
    flex-direction: column;
    margin: 0.5rem;
  }
  
  /* 编辑器和预览区域在移动端垂直堆叠 */
  .editor, .preview {
    width: 100%;
    margin: 0.2rem 0;
  }
  
  /* 移除编辑器右侧边框 */
  .editor {
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  /* 调整标题大小 */
  h1 {
    font-size: 1.5rem;
  }
  
  /* 调整工具栏宽度 */
  .toolbar {
    width: 98%;
    max-width: none;
  }
  
  /* 工具栏按钮调整 - 修改以下部分 */
  .toolbar-content {
    flex-direction: row; /* 改为行布局 */
    align-items: center; /* 居中对齐 */
    justify-content: flex-start; /* 左对齐 */
    flex-wrap: wrap; /* 允许换行 */
  }
  
  .toolbar-content button {
    width: auto; /* 改为自动宽度 */
    margin-bottom: 0.3rem;
    padding: 0.2rem 0.4rem; /* 减小内边距 */
    font-size: 0.8rem; /* 减小字体大小 */
    min-height: 28px; /* 减小最小高度 */
  }
  
  /* 调整主题选择器和设置按钮 */
  .header-controls {
    gap: 0.5rem;
  }
  
  .theme-selector {
    gap: 0.3rem;
  }
  
  .theme-btn, .settings-btn {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }
}

/* 针对小屏幕设备的额外调整 */
@media screen and (max-width: 480px) {
  .header {
    padding: 0.5rem;
  }
  
  h1 {
    font-size: 1.3rem;
  }
  
  .editor, .preview {
    padding: 0.5rem;
  }
  
  .toolbar {
    padding: 0.5rem;
  }
  
  .toolbar-content button {
    padding: 0.3rem 0.5rem; /* 稍微增加内边距以提高可点击性 */
    font-size: 0.85rem;
  }
}

/* 鼠标光晕效果 - 编辑区和预览区 */
.editor-container {
  position: relative;
}

/* JavaScript动态更新光晕位置 */
.mouse-glow {
  position: absolute;
  width: 300px; /* 增大光晕尺寸 */
  height: 300px; /* 增大光晕尺寸 */
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.139) 0%, rgba(255, 255, 255, 0) 50%, transparent 80%); /* 降低透明度并设置更线性的渐变效果 */
}

.mouse-glow.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.5);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.139) 0%, rgba(255, 255, 255, 0) 50%, transparent 80%); /* 进一步降低透明度 */
}
